package com.zlict.admin.controller;

import com.zlict.admin.domain.ProjectIntangibleassets;
import com.zlict.admin.service.IProjectIntangibleassetsService;
import com.zlict.common.annotation.Log;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import com.zlict.common.core.page.TableDataInfo;
import com.zlict.common.enums.BusinessType;
import com.zlict.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 项目无形资产管理Controller
 * 
 * @author dzw
 * @date 2025-06-16
 */
@RestController
@RequestMapping("/admin/intangibleassets")
public class ProjectIntangibleassetsController extends BaseController
{
    @Autowired
    private IProjectIntangibleassetsService projectIntangibleassetsService;

    /**
     * 查询项目无形资产管理列表
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleassets:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectIntangibleassets projectIntangibleassets)
    {
        startPage();
        List<ProjectIntangibleassets> list = projectIntangibleassetsService.selectProjectIntangibleassetsList(projectIntangibleassets);
        return getDataTable(list);
    }

    /**
     * 导出项目无形资产管理列表
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleassets:export')")
    @Log(title = "项目无形资产管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectIntangibleassets projectIntangibleassets)
    {
        List<ProjectIntangibleassets> list = projectIntangibleassetsService.selectProjectIntangibleassetsList(projectIntangibleassets);
        ExcelUtil<ProjectIntangibleassets> util = new ExcelUtil<ProjectIntangibleassets>(ProjectIntangibleassets.class);
        util.exportExcel(response, list, "项目无形资产管理数据");
    }

    /**
     * 获取项目无形资产管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleassets:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(projectIntangibleassetsService.selectProjectIntangibleassetsById(id));
    }

    /**
     * 新增项目无形资产管理
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleassets:add')")
    @Log(title = "项目无形资产管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectIntangibleassets projectIntangibleassets)
    {
        return toAjax(projectIntangibleassetsService.insertProjectIntangibleassets(projectIntangibleassets));
    }

    /**
     * 修改项目无形资产管理
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleassets:edit')")
    @Log(title = "项目无形资产管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectIntangibleassets projectIntangibleassets)
    {
        return toAjax(projectIntangibleassetsService.updateProjectIntangibleassets(projectIntangibleassets));
    }

    /**
     * 删除项目无形资产管理
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleassets:remove')")
    @Log(title = "项目无形资产管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectIntangibleassetsService.deleteProjectIntangibleassetsByIds(ids));
    }
}
